#include <stdio.h>
#include <stdlib.h>

#include "list.h"

int main(int argc, char* argv[]) {
    list_t* list = new_list_node(1);  //新建链表头结点

    //插入结点
    list = list_add(list, 2);
    list = list_add(list, 5);
    list = list_add(list, 6);
    list = list_add(list, 10);
    list = list_add(list, 16);
    list = list_add(list, 15);

    list_print(list);  //打印链表
    list = list_delete(list, 10);
    list_print(list);  //打印链表

    list_t* node = list_index_of(list, 3);   //找到索引3的链表结点（索引从0开始）
    printf("node->data = %d\n", node->data);

    list = list_delete_node(list, node);   //删除结点
    list_print(list);  //打印链表

    list_destroy(list);  //销毁链表
    list = NULL;

    return 0;
}